/**
  ******************************************************************************
  * @file    STM32F0xx_IAP/inc/main.h
  * @author  MCD Application Team
  * @version V1.0.0
  * @date    29-May-2012
  * @brief   Header for main.c module
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; COPYRIGHT 2012 STMicroelectronics</center></h2>
  *
  * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  * You may not use this file except in compliance with the License.
  * You may obtain a copy of the License at:
  *
  *        http://www.st.com/software_license_agreement_liberty_v2
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  *
  ******************************************************************************
  */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MAIN_H
#define __MAIN_H

/* Includes ------------------------------------------------------------------*/
#include "stm32f0xx.h"
#include "stm320518_eval.h"
#include <stdio.h>
#include "menu.h"
#include "Global_types.h"
#include "Sensor.h"
#include "Condition.h"
#include "Task.h"
#include "Scheduler.h"
#include "CommandHandler.h"
#include "TimeManager.h"
#include "stm32f0xx_usart.h"
#include "Global_types.h"
#include "Scheduler.h"
#include "SerialInterface.h"
//#include "GPIO.hpp"

/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
void Display_Init(void);
void Display(void);
extern uint8_t byte;

inline void SysTick_CallBack(void)
{
    TimeManager::UpdateSystemTime();
}
inline void USART_ByteReceived(void)
{
ErrorCode err;
byte= USART_ReceiveData(USART1);
if(byte!='\b')
{
  err=CommandHandler::addMessagebyte(byte);
}
else
{
 err=CommandHandler::pullMessagebyte();
}
if(err==NO_ERR)
 {
  SerialPutChar(byte);
  if(byte==CommandHandler::messageEndChar)
  {
   Scheduler::sendEvent(COMMAND_RECEIVED);
   return;
  }
 }
}


#endif /* __MAIN_H */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

